package hibernate.patterns;

import org.hibernate.type.StringType;

public class ColourType extends UserTypeBase<Colour, String> {
    @Override
    public int[] sqlTypes() {
        return new int[]{new StringType().sqlType()};
    }

    @Override
    protected Colour createObject(String baseValue) {
        return Colour.RED;
    }

    @Override
    protected String convertSqlToBaseType(Object value) {
        return (String) value;
    }

    @Override
    protected Colour getNullValue() {
        return Colour.NULL;
    }

    @Override
    protected String convertModelToBaseType(Colour colour) {
        return colour.name();
    }
}
